from flask import Flask
from flask_socketio import SocketIO
from datetime import timedelta
socketio=SocketIO()

def create_app():
    app=Flask(__name__)

    # flask 设置
    # app.debug=True
    app.config["SECRET_KEY"] = "YgTHBVGH>?KJJ@@#445Jjkdas"  # 生成session秘钥
    app.config["PERMANENT_SESSION_LIFETIME"] = timedelta(days=7)  # 设置session秘钥过期日期,不设置则关闭浏览器就失效

    # 初始化socketio
    socketio.init_app(app=app,cors_allowed_origins='*')

    # 蓝图可以多级注册:home.register_blueprint(home的子蓝图)
    # 导入例子模块
    from module.aaa_example import example
    app.register_blueprint(example)
    # 导入主页模块
    from module.home import home
    app.register_blueprint(home)
    # 导入漫画模块
    from module.man_hua import man_hua
    app.register_blueprint(man_hua)
    # 导入笔记模块
    from module.bi_ji import bi_ji
    app.register_blueprint(bi_ji)
    # 导入视频播放模块
    from module.video import mvideo
    app.register_blueprint(mvideo)

    return app
